package com.hx.oracle;

import com.hx.oracle.entity.Regions;
import com.hx.oracle.utils.DBUtils;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;

public class Base {
    public static void main(String[] args) {

        String sql="select * from regions where region_name =?";
        try {
            ResultSet rs= DBUtils.query(sql,"Europe");
            rs.next();
            System.out.println(rs.getInt(1)+"\t"+rs.getString(2));
            List<Regions>regions=new ArrayList<>();
            while (rs.next()){
                regions.add(new Regions(rs.getInt(1),rs.getString(2)));
            }
            rs.close();
            for(Regions r:regions){
                System.out.println(r);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}